package com.oops.controller;

import com.oops.service.OrderService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * TODO: 秒杀接口
 *
 * @author wuyijie
 * @date 2022/4/16 21:44
 */
@Slf4j
@RestController
@RequestMapping("secKill")
public class SecKillController {

    private OrderService orderService;

    public SecKillController(OrderService orderService) {
        this.orderService = orderService;
    }

    @GetMapping("test/{id}")
    public String sendMessage(@PathVariable String id) {
        orderService.sendMessage(id);
        return "ok";
    }

    @GetMapping("/{goodsId}")
    public Boolean seckill(@PathVariable Long goodsId) {
        return orderService.seckill(goodsId);
    }

    // @GetMapping("pay/{orderId}")
    // public String pay(@PathVariable Long orderId) {
    //     return orderService.pay(orderId);
    // }
}
